package com.sojson.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sojson.project.entity.po.UserActivity;
import com.sojson.project.service.UserActivityService;
import com.sojson.result.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户参加活动控制器
 * 
 * @author liu
 * @date 2021-06-07
 */
@Api(tags = "用户参加活动管理")
@RestController
@RequestMapping("/userActivity")
public class UserActivityController {

    @Autowired
    private UserActivityService userActivityService;

    /**
     * 单条插入
     * 
     * @param userActivity
     * @return
     */
    @PostMapping("/insert")
    @PreAuthorize("@ss.hasPermi('/userActivity/insert')")
    @ApiOperation("给用户参加活动添加一条数据")
    public Result<Integer> insert(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.insert(userActivity));
    }

    /**
     * 批量插入
     * 
     * @param userActivity
     * @return
     */
    @PostMapping("/insertList")
    @PreAuthorize("@ss.hasPermi('/userActivity/insertList')")
    @ApiOperation("给用户参加活动添加多条数据")
    public Result<Integer> insertList(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.insertList(userActivity));
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param userActivity
     * @return
     */
    @DeleteMapping("/deleteByDto")
    @PreAuthorize("@ss.hasPermi('/userActivity/deleteByDto')")
    @ApiOperation("通过对象批量删除用户参加活动数据(物理删除)")
    public Result<Integer> deleteByDto(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.deleteByDto(userActivity));
    }

    /**
     * 统计全部数量
     * 
     * @return
     */
    @GetMapping("/countAll")
    @PreAuthorize("@ss.hasPermi('/userActivity/countAll')")
    @ApiOperation("统计用户参加活动全部数据(包含逻辑删除的)")
    public Result<Integer> countAll() {
        return Result.success(userActivityService.countAll());
    }

    /**
     * 查询所有
     * 
     * @return
     */
    @GetMapping("/listAll")
    @PreAuthorize("@ss.hasPermi('/userActivity/listAll')")
    @ApiOperation("查询用户参加活动所有数据(包含逻辑删除的)")
    public Result<List<UserActivity>> listAll() {
        return Result.success(userActivityService.listAll());
    }

    /**
     * 根据对象统计数量
     * 
     * @param userActivity
     * @return
     */
    @GetMapping("/countByDto")
    @PreAuthorize("@ss.hasPermi('/userActivity/countByDto')")
    @ApiOperation("根据对象统计用户参加活动数据")
    public Result<Integer> countByDto(UserActivity userActivity) {
        return Result.success(userActivityService.countByDto(userActivity));
    }

    /**
     * 根据对象查询
     * 
     * @param userActivity
     * @return
     */
    @GetMapping("/listByDto")
    @PreAuthorize("@ss.hasPermi('/userActivity/listByDto')")
    @ApiOperation("根据对象查询用户参加活动数据")
    public Result<List<UserActivity>> listByDto(UserActivity userActivity) {
        return Result.success(userActivityService.listByDto(userActivity));
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     */
    @DeleteMapping("/deleteById/{id}")
    @PreAuthorize("@ss.hasPermi('/userActivity/deleteById/{id}')")
    @ApiOperation("通过id删除用户参加活动数据(物理删除)")
    public Result<Integer> deleteById(@PathVariable Integer id) {
        if (id == null) {
            return Result.success();
        }

        return Result.success(userActivityService.deleteById(id));
    }

    /**
     * 通过id数组删除(物理删除)
     * 
     * @param ids
     * @return
     */
    @DeleteMapping("/deleteByIds/{ids}")
    @PreAuthorize("@ss.hasPermi('/userActivity/deleteByIds')")
    @ApiOperation("通过id数组删除用户参加活动数据(物理删除)")
    public Result<Integer> deleteByIds(@PathVariable Integer[] ids) {
        if (ids.length == 0) {
            return Result.success();
        }

        return Result.success(userActivityService.deleteByIds(ids));
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateAllById")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateAllById')")
    @ApiOperation("通过id更新用户参加活动数据(全部更新)")
    public Result<Integer> updateAllById(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateAllById(userActivity));
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateAllByIdList")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateAllByIdList')")
    @ApiOperation("通过id列表更新用户参加活动数据(全部更新)(更新内容相同)")
    public Result<Integer> updateAllByIdList(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateAllByIdList(userActivity));
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateDtoListAllById")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateDtoListAllById')")
    @ApiOperation("通过id列表更新用户参加活动数据(全部更新)(更新内容不相同)")
    public Result<Integer> updateDtoListAllById(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateDtoListAllById(userActivity));
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateById")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateById')")
    @ApiOperation("通过id更新用户参加活动数据(局部更新)")
    public Result<Integer> updateById(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateById(userActivity));
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateByIdList")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateByIdList')")
    @ApiOperation("通过id列表更新用户参加活动数据(局部更新)(更新内容相同)")
    public Result<Integer> updateByIdList(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateByIdList(userActivity));
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateDtoListById")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateDtoListById')")
    @ApiOperation("通过id列表更新用户参加活动数据(局部更新)(更新内容不相同)")
    public Result<Integer> updateDtoListById(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateDtoListById(userActivity));
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     */
    @GetMapping("/findById/{id}")
    @PreAuthorize("@ss.hasPermi('/userActivity/findById/{id}')")
    @ApiOperation("通过id查询用户参加活动数据")
    public Result<UserActivity> findById(@PathVariable Integer id) {
        if (id == null) {
            return Result.success();
        }

        return Result.success(userActivityService.findById(id));
    }

    /**
     * 通过id数组查询
     * 
     * @param ids
     * @return
     */
    @GetMapping("/findByIds/{ids}")
    @PreAuthorize("@ss.hasPermi('/userActivity/findByIds/{ids}')")
    @ApiOperation("通过id数组查询用户参加活动数据")
    public Result<List<UserActivity>> findByIds(@PathVariable Integer[] ids) {
        if (ids.length == 0) {
            return Result.success();
        }

        return Result.success(userActivityService.findByIds(ids));
    }

    /**
     * 通过对象查询id列表
     * 
     * @param userActivity
     * @return
     */
    @GetMapping("/findIdByDto")
    @PreAuthorize("@ss.hasPermi('/userActivity/findIdByDto')")
    @ApiOperation("通过对象查询用户参加活动id列表")
    public Result<List<Integer>> findIdByDto(UserActivity userActivity) {
        return Result.success(userActivityService.findIdByDto(userActivity));
    }

    /**
     * 通过no删除(物理删除)
     * 
     * @param no
     * @return
     */
    @DeleteMapping("/deleteByNo/{no}")
    @PreAuthorize("@ss.hasPermi('/userActivity/deleteByNo/{no}')")
    @ApiOperation("通过no删除用户参加活动数据(物理删除)")
    public Result<Integer> deleteByNo(@PathVariable String no) {
        if (no == null) {
            return Result.success();
        }

        return Result.success(userActivityService.deleteByNo(no));
    }

    /**
     * 通过no数组删除(物理删除)
     * 
     * @param nos
     * @return
     */
    @DeleteMapping("/deleteByNos/{nos}")
    @PreAuthorize("@ss.hasPermi('/userActivity/deleteByNos/{nos}')")
    @ApiOperation("通过no数组删除用户参加活动数据(物理删除)")
    public Result<Integer> deleteByNos(@PathVariable String[] nos) {
        if (nos.length == 0) {
            return Result.success();
        }

        return Result.success(userActivityService.deleteByNos(nos));
    }

    /**
     * 通过no更新(全部更新)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateAllByNo")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateAllByNo')")
    @ApiOperation("通过no更新用户参加活动数据(全部更新)")
    public Result<Integer> updateAllByNo(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateAllByNo(userActivity));
    }

    /**
     * 通过no列表更新(全部更新)(更新内容相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateAllByNoList")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateAllByNoList')")
    @ApiOperation("通过no列表更新用户参加活动数据(全部更新)(更新内容相同)")
    public Result<Integer> updateAllByNoList(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateAllByNoList(userActivity));
    }

    /**
     * 通过no列表更新(全部更新)(更新内容不相同)
     * 
     * @param userActivitys
     * @return
     */
    @PutMapping("/updateDtoListAllByNo")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateDtoListAllByNo')")
    @ApiOperation("通过no列表更新用户参加活动数据(全部更新)(更新内容不相同)")
    public Result<Integer> updateDtoListAllByNo(@RequestBody UserActivity userActivitys) {
        return Result.success(userActivityService.updateDtoListAllByNo(userActivitys));
    }

    /**
     * 通过no更新(局部更新)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateByNo")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateByNo')")
    @ApiOperation("通过no更新用户参加活动数据(局部更新)")
    public Result<Integer> updateByNo(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateByNo(userActivity));
    }

    /**
     * 通过no列表更新(局部更新)(更新内容相同)
     * 
     * @param userActivity
     * @return
     */
    @PutMapping("/updateByNoList")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateByNoList')")
    @ApiOperation("通过no列表更新用户参加活动数据(局部更新)(更新内容相同)")
    public Result<Integer> updateByNoList(@RequestBody UserActivity userActivity) {
        return Result.success(userActivityService.updateByNoList(userActivity));
    }

    /**
     * 通过no列表更新(局部更新)(更新内容不相同)
     * 
     * @param userActivitys
     * @return
     */
    @PutMapping("/updateDtoListByNo")
    @PreAuthorize("@ss.hasPermi('/userActivity/updateDtoListByNo')")
    @ApiOperation("通过no列表更新用户参加活动数据(局部更新)(更新内容不相同)")
    public Result<Integer> updateDtoListByNo(@RequestBody UserActivity userActivitys) {
        return Result.success(userActivityService.updateDtoListByNo(userActivitys));
    }

    /**
     * 通过no查询
     * 
     * @param no
     * @return
     */
    @GetMapping("/findByNo/{no}")
    @PreAuthorize("@ss.hasPermi('/userActivity/findByNo/{no}')")
    @ApiOperation("通过no查询用户参加活动数据")
    public Result<UserActivity> findByNo(@PathVariable String no) {
        if (no == null) {
            return Result.success();
        }

        return Result.success(userActivityService.findByNo(no));
    }

    /**
     * 通过no数组查询
     * 
     * @param nos
     * @return
     */
    @GetMapping("/findByNos/{nos}")
    @PreAuthorize("@ss.hasPermi('/userActivity/findByNos/{nos}')")
    @ApiOperation("通过no数组查询用户参加活动数据")
    public Result<List<UserActivity>> findByNos(@PathVariable String[] nos) {
        if (nos.length == 0) {
            return Result.success();
        }

        return Result.success(userActivityService.findByNos(nos));
    }

    /**
     * 通过对象查询no列表
     * 
     * @param userActivity
     * @return
     */
    @GetMapping("/findNoByDto")
    @PreAuthorize("@ss.hasPermi('/userActivity/findNoByDto')")
    @ApiOperation("通过对象查询用户参加活动no列表")
    public Result<List<String>> findNoByDto(UserActivity userActivity) {
        return Result.success(userActivityService.findNoByDto(userActivity));
    }

    /**
     * 清空数据(物理清空)
     * 
     * @return
     */
    @DeleteMapping("/clear")
    @PreAuthorize("@ss.hasPermi('/userActivity/clear')")
    @ApiOperation("清空用户参加活动数据(物理清空)")
    public Result<Integer> clear() {
        return Result.success(userActivityService.clear());
    }

}